//
//  FormalLoanTableViewCell.m
//  LoanOne
//
//  Created by WangZhenyu on 2017/10/9.
//  Copyright © 2017年 WangZhenyu. All rights reserved.
//

#import "FormalLoanTableViewCell.h"
#import "GlobalFunction.h"

@interface FormalLoanTableViewCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *applyLabel;
@property (weak, nonatomic) IBOutlet UILabel *amountLabel;
@property (weak, nonatomic) IBOutlet UILabel *lixiLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailLabel;
@property (weak, nonatomic) IBOutlet UIImageView *tagImageView;

@end

@implementation FormalLoanTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.detailLabel.layer.masksToBounds = YES;
    self.detailLabel.layer.cornerRadius = 11.0f;
    self.detailLabel.layer.borderColor = TextGrayColor.CGColor;
    self.detailLabel.layer.borderWidth = 0.5f;
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setContent:(ProductItem *)item{
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:item.icon]];
    self.nameLabel.text = item.title;
    self.applyLabel.text = item.applyCount;
    changeLabelAttribute(self.applyLabel, 0, 4, TextColor, FormalThemeColor, 11);
    self.amountLabel.text = [NSString stringWithFormat:@"%@：%@", item.amountDisplay, item.amount];
    changeLabelAttribute(self.amountLabel, 0, item.amount.length, RGB(246, 53, 59), TextGrayColor, 13);
    self.lixiLabel.text = [NSString stringWithFormat:@"%@：%@", item.interestDisplay, item.interest];
    changeLabelAttribute(self.lixiLabel, 0, item.interest.length, RGB(246, 53, 59), TextGrayColor, 13);
    self.detailLabel.text = item.descriptionStr;
    CGSize labelSize = [self.detailLabel.text boundingRectWithSize:CGSizeMake(SCREEN_WIDTH_DEVICE - 15 - 18, 22) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0]} context:nil].size;
    [self.detailLabel setFrame:CGRectMake(self.detailLabel.frame.origin.x, self.detailLabel.frame.origin.y, labelSize.width + 10, 22)];
    [self.tagImageView sd_setImageWithURL:[NSURL URLWithString:item.tagIcon]];
}

@end
